// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   pk1.YCCtbl.java

package MaintMenu.VenPricingUpdTBLN;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class APtest
{

    public APtest()

    {
        int x=0;
        int y=0;
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection conli = DriverManager.getConnection(dbURL, "", "");
            //Statement stli = conli.createStatement();



//            String dataSourceName6 = "dbBL";
//            String dbURL6 = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName6).toString();
//            Connection conbk = DriverManager.getConnection(dbURL6, "", "");
//            Statement stbk1 = conbk.createStatement();
//            Statement stbk2 = conbk.createStatement();
//            Statement stbk3 = conbk.createStatement();

            //Here is where you enter SQL Statements

            //clean up fields

            String st[] = new String[18];
            st[0] = ("UPDATE tblbcn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
            st[1] = ("UPDATE tblhfn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
            st[2] = ("UPDATE tblotn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");

            //clean up MASTER Category file
            st[3] = ("UPDATE bcmast SET gd_no=null");
            st[4] = ("UPDATE hfmast SET gd_no=null");
            st[5] = ("UPDATE otmast SET gd_no=null");


            //update Vendor part# on BCMAST master file using PARTLINK #.
            st[6] = ("UPDATE bcmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=true and b.capa='y';");
            st[7] = ("UPDATE bcmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa is null and b.capa is null;");

            //update Vendor part# on HFMAST master file using PARTLINK #.
            st[8] = ("UPDATE hfmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=true and b.capa='y';");
            st[9]= ("UPDATE hfmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa is null and b.capa is null;");

            //update Vendor part# on OTMAST master file using PARTLINK #.
            st[10]= ("UPDATE otmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=true and b.capa='y';");
            st[11]= ("UPDATE otmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa is null and b.capa is null;");




            //update Vendor Pricing using PARTLINK#
            st[12]= ("UPDATE tblbcn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=False AND b.CAPA is null;");

            st[13]= ("UPDATE tblbcn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=true AND b.CAPA='y';");

            st[14]= ("UPDATE tblhfn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=False AND b.CAPA is null;");

            st[15]= ("UPDATE tblhfn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=true AND b.CAPA='y';");

            st[16]= ("UPDATE tblotn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=False AND b.CAPA is null;");

            st[17]= ("UPDATE tblotn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=true AND b.CAPA='y';");





            for (x=1; x<st.length;x++){
                Statement stli = conli.createStatement();

                try {

                    stli.execute(st[x]);

                }catch(SQLException er) {
                    er.printStackTrace();
                }stli.close();
            }



//            stbk1.close();
//            stbk2.close();
//            stbk3.close();
            conli.close();
//            conbk.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}
